package simulationEnviroment;

import java.util.Vector;

import simulationEngine.SimulationEngine;
import datatypes.HostAction;

public class Clock {

	private int stepNumber = -1;
	private SimulationEngine container = null;
		
	//one makrostep = 20 units
	//--> Every 100 / 20 = 5 Simulations Steps a Timestep Notification is given to 
	private static final float MAKROSTEP = 20.0F;
	private static final float UNIT = 20.0F;
	
	
	public Clock (SimulationEngine engine){
		this.container = engine;
	}
	
	public void onProcessorReady() {
		this.stepNumber ++;
		this.container.getMiniworld().doManipulate();
		this.container.getScheduler().startStep(stepNumber);
	}
	
	
	public void onCleanroomCall (Vector<HostAction> actions){
		this.container.getMiniworld().doManipulate();
		this.container.getMiniworld().newSimulationInvokationApi(stepNumber, actions);		
		this.stepNumber ++ ;
	}
	
	public int getCurrentTime(){
		return this.stepNumber;
	}
	
	public static int getNotificationRate(){
		return Math.round(MAKROSTEP / UNIT);
	}
}
